package com.bo.ivolatile;

/**
 * @Author: gpb
 * @Date: 2024/7/31 10:40
 * @Description:
 */
public class Sync {
    static boolean flag = true;

    public static void main (String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            while (flag) {
                synchronized (Sync.class) {
                }
            }
            System.out.println(Thread.currentThread().getName() + "线程结束");
        });
        thread.start();
        Thread.sleep(100);
        flag = false;
    }
}
